/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 *
 *MpmWorkingCalendarController
 * 工作日历
 *
 * 修改纪录
 * 2021-07-05 版本：1.0 wudaliang 创建。
 * @version 版本：1.0
 * @author 作者：wudaliang
 * 创建日期：2021-07-05
 */

package com.topscomm.mpm.controller;

import com.topscomm.mpm.service.impl.MpmWorkingCalendarService;
import com.topscomm.pub.util.SpringUtil;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topscomm.mpm.controller.auto.MpmWorkingCalendarControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: wudaliang
 * @date: 2021-07-05
 * @description:工作日历Controller
 * @modify:
 */
@RestController
@RequestMapping("mpm/workingCalendar")
public class MpmWorkingCalendarController extends MpmWorkingCalendarControllerAuto implements IMpmWorkingCalendarController {
	/**
	 * @author: wudaliang
	 * @date: 2021-07-05
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_user")) {
			String value = paraMap.get("qry_user").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and (username like '%{0}%' or usercode = '{0}') ", value);
		}
		if (paraMap.containsKey("qry_code")) {
			String value = paraMap.get("qry_code").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and code = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: wudaliang
	 * @date: 2021-07-05
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}


	@PostMapping(value = "/batchAdd")
	public ResponseResult<Object> batchAdd(@RequestBody(required = false) Map<String, Object> paraMap) {
		  MpmWorkingCalendarService mpmWorkingCalendarService=(MpmWorkingCalendarService) SpringUtil
			.getBean("mpmWorkingCalendarService");
		mpmWorkingCalendarService.insertCalendarBatch(paraMap);
		return ResponseResult.ok("添加成功");

	}
}

